﻿using AutoMapper;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Portal.Model;
using Portal.Presentation.Models;
using Rhino.Mocks;

namespace Portal.Presentation.Tests.Units.AutoMapper
{
	[TestClass]
	public class UserInfoInterfaceToUserInfoViewModelTests : BaseTests
	{
		protected override void InitializeTest()
		{
		}

		[TestMethod]
		public void UserInfoInterface_New_UserInfoViewModel()
		{
			var userInfo = Mocks.Stub<IUserInfo>();
			var user = Mocks.Stub<IUser>();

			SetupResult.For(user.Login).Return("login");
			user.LastName = "last name";
			user.FirstName = "first name";
			userInfo.User = user;

			var primaryPhone = Mocks.Stub<IContactInfo>();
			primaryPhone.Value = "primaryPhone";
			userInfo.PrimaryPhone = primaryPhone;

			var secondaryPhone = Mocks.Stub<IContactInfo>();
			secondaryPhone.Value = "secondaryPhone";
			userInfo.SecondaryPhone = secondaryPhone;

			var primaryEmail = Mocks.Stub<IContactInfo>();
			primaryEmail.Value = "primaryEmail";
			userInfo.PrimaryEmail = primaryEmail;

			var secondaryEmail = Mocks.Stub<IContactInfo>();
			secondaryEmail.Value = "secondaryEmail";
			userInfo.SecondaryEmail = secondaryEmail;

			Mocks.ReplayAll();

			var model = userInfo.MapNew<IUserInfo, UserInfoDataModel>();

			model.FirstName.Should().Be(user.FirstName);
			model.LastName.Should().Be(user.LastName);
			model.PrimaryEmail.Should().Be(primaryEmail.Value);
			model.SecondaryEmail.Should().Be(secondaryEmail.Value);
			model.PrimaryPhone.Should().Be(primaryPhone.Value);
			model.SecondaryPhone.Should().Be(secondaryPhone.Value);
		}
	}
}